const mysql = require('mysql');

const connection = mysql.createConnection({
    host: 'localhost',
    user: 'root',
    password: 'root',
    database: 'books'
});

connection.connect();

let _book = {
    name: '四大名捕',
    author: '温瑞安',
    category: '文学',
    description: '武侠小说，讲述无情、铁手、追命、冷血的故事'
};
let _sql = "UPDATE t_book SET name=?, author=?, category=?, description=? WHERE id=?";
let _id = 9;
let _data = ['测试1', '温瑞安', '文学', '测试.....', _id];
let query = connection.query(_sql, _data, (err, results, fields)=>{
    if (err) throw err;
    console.log(query.sql);
    console.log('insertId: ', results.insertId);
    console.log('affectedRows: ', results.affectedRows);

    connection.end();
});


// connection.end();
